package cn.yuli.commad.impl;

import cn.yuli.commad.Command;
import cn.yuli.receiver.CeilingFan;

public class CeilingFanHighCommand implements Command {
	private int preSpeed;
	private CeilingFan ceilingFan;
	public CeilingFanHighCommand(CeilingFan ceilingFan) {
		this.ceilingFan = ceilingFan;
	}
	@Override
	public void excute() {
		ceilingFan.high();
		preSpeed = CeilingFan.HIGH;
	}

	@Override
	public void undo() {
		if(preSpeed == CeilingFan.HIGH){
			ceilingFan.high();
		}else if(preSpeed == CeilingFan.MEDIUM){
			ceilingFan.medium();
		}else if(this.preSpeed == CeilingFan.LOW){
			ceilingFan.low();
		}else if(this.preSpeed == CeilingFan.OFF){
			ceilingFan.off();
		}
			
	}

}
